package com.bwie.controller;

import com.bwie.common.domain.Role;
import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import com.bwie.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: SysUserController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘鑫
 * @date: 2025/8/24 11:41
 */
@CrossOrigin
@RestController
@RequestMapping("sysUser")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    /**
     * 登录
     * @param user
     * @return
     */
    @PostMapping("login")
    public Result<User> login(@RequestBody User user){
        return Result.success(sysUserService.login(user));
    }

    /**
     * 查询用户对应的角色
     * @param userId
     * @return
     */
    @GetMapping("getRoleList/{userId}")
    public Result<List<Role>> getRoleList(@PathVariable("userId") Integer userId){
        return Result.success(sysUserService.getRoleList(userId));
    }
    /**
     * 查询用户的积分返回给前端
     * @param userId
     * @return
     */
    @GetMapping("getUserIntegral/{userId}")
    public Result<User> getUserIntegral(@PathVariable("userId") Integer userId){
        return Result.success(sysUserService.getUserIntegral(userId));
    }
}
